<!DOCTYPE html>
<html>

<head>
  <meta charset="utf-8">

  <!-- PACE Progress Bar START -->
  
  

  <!-- PACE Progress Bar START -->

  
  <title>
    
    python+opencv教程挑战任务：画动态时钟 |
    
    ex2tron&#39;s Tech Blog
  </title>
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  
  <meta name="keywords" content="ex2tron,opencv,tensorflow" />
  
  
  
  
  <meta name="description" content="挑战任务：使用OpenCV绘制一个随系统时间动态变化的时钟。">
<meta name="keywords" content="OpenCV,Python,图像处理,PyQt">
<meta property="og:type" content="article">
<meta property="og:title" content="Python+OpenCV教程挑战任务：画动态时钟">
<meta property="og:url" content="http://ex2tron.wang/opencv-python-clock-drawing/index.html">
<meta property="og:site_name" content="ex2tron&#39;s Tech Blog">
<meta property="og:description" content="挑战任务：使用OpenCV绘制一个随系统时间动态变化的时钟。">
<meta property="og:locale" content="en">
<meta property="og:image" content="http://pic.ex2tron.top/cv2_draw_clock_dynamic_sample.gif">
<meta property="og:updated_time" content="2018-12-02T13:11:45.117Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="Python+OpenCV教程挑战任务：画动态时钟">
<meta name="twitter:description" content="挑战任务：使用OpenCV绘制一个随系统时间动态变化的时钟。">
<meta name="twitter:image" content="http://pic.ex2tron.top/cv2_draw_clock_dynamic_sample.gif">
  
  <link rel="alternate" href="/atom.xaml" title="ex2tron&#39;s Tech Blog" type="application/atom+xml">
  
  <link rel="icon" href="/img/bookshelf.ico">
  <link href="https://fonts.googleapis.com/css?family=Open+Sans|Montserrat:700" rel="stylesheet" type="text/css">
  <link href="https://fonts.googleapis.com/css?family=Roboto:400,300,300italic,400italic" rel="stylesheet" type="text/css">
  <link href="//cdn.bootcss.com/font-awesome/4.6.3/css/font-awesome.min.css" rel="stylesheet">
  <style type="text/css">
    @font-face {
      font-family: futura-pt;
      src: url(https://use.typekit.net/af/9749f0/00000000000000000001008f/27/l?subset_id=2&fvd=n5) format("woff2");
      font-weight: 500;
      font-style: normal;
    }

    @font-face {
      font-family: futura-pt;
      src: url(https://use.typekit.net/af/90cf9f/000000000000000000010091/27/l?subset_id=2&fvd=n7) format("woff2");
      font-weight: 500;
      font-style: normal;
    }

    @font-face {
      font-family: futura-pt;
      src: url(https://use.typekit.net/af/8a5494/000000000000000000013365/27/l?subset_id=2&fvd=n4) format("woff2");
      font-weight: lighter;
      font-style: normal;
    }

    @font-face {
      font-family: futura-pt;
      src: url(https://use.typekit.net/af/d337d8/000000000000000000010095/27/l?subset_id=2&fvd=i4) format("woff2");
      font-weight: 400;
      font-style: italic;
    }
  </style>

  <link rel="stylesheet" id="athemes-headings-fonts-css" href="//fonts.googleapis.com/css?family=Yanone+Kaffeesatz%3A200%2C300%2C400%2C700&amp;ver=4.6.1"
    type="text/css" media="all">
  <link rel="stylesheet" href="/css/style.css">

  <script src="/js/jquery-3.1.1.min.js"></script>

  <!-- Bootstrap core CSS -->
  <link rel="stylesheet" href="/css/bootstrap.css">
  <link rel="stylesheet" href="/css/hiero.css">
  <link rel="stylesheet" href="/css/glyphs.css">
  
  <link rel="stylesheet" href="/css/vdonate.css">
  

  <!-- Custom CSS -->
  <link rel="stylesheet" href="/css/my.css">

  <script>
    (function () {
      var bp = document.createElement('script');
      var curProtocol = window.location.protocol.split(':')[0];
      if (curProtocol === 'https') {
        bp.src = 'https://zz.bdstatic.com/linksubmit/push.js';
      }
      else {
        bp.src = 'http://push.zhanzhang.baidu.com/push.js';
      }
      var s = document.getElementsByTagName("script")[0];
      s.parentNode.insertBefore(bp, s);
    })();
  </script>

</head>
<script>
var themeMenus = {};

  themeMenus["/"] = "Home"; 

  themeMenus["/archives"] = "Archives"; 

  themeMenus["/categories"] = "Categories"; 

  themeMenus["/tags"] = "Tags"; 

  themeMenus["/about"] = "About"; 

</script>


  <body data-spy="scroll" data-target="#toc" data-offset="50">


  <header id="allheader" class="site-header" role="banner">
  <div class="clearfix container">
      <div class="site-branding">

          <h1 class="site-title">
            
              <a href="/" title="ex2tron&#39;s Tech Blog" rel="home"> ex2tron&#39;s Tech Blog </a>
            
          </h1>

          
            
          <nav id="main-navigation" class="main-navigation" role="navigation">
            <a class="nav-open">Menu</a>
            <a class="nav-close">Close</a>
            <div class="clearfix sf-menu">

              <ul id="main-nav" class="nmenu sf-js-enabled">
                    
                      <li class="menu-item menu-item-type-custom menu-item-object-custom menu-item-home menu-item-1663"> <a class="" href="/">Home</a> </li>
                    
                      <li class="menu-item menu-item-type-custom menu-item-object-custom menu-item-home menu-item-1663"> <a class="" href="/archives">Archives</a> </li>
                    
                      <li class="menu-item menu-item-type-custom menu-item-object-custom menu-item-home menu-item-1663"> <a class="" href="/categories">Categories</a> </li>
                    
                      <li class="menu-item menu-item-type-custom menu-item-object-custom menu-item-home menu-item-1663"> <a class="" href="/tags">Tags</a> </li>
                    
                      <li class="menu-item menu-item-type-custom menu-item-object-custom menu-item-home menu-item-1663"> <a class="" href="/about">About</a> </li>
                    
              </ul>
            </div>
          </nav>


      </div>
  </div>
</header>




  <div id="container">
    <div id="wrap">
            
      <div id="content" class="outer">
        
          <section id="main" style="float:none;"><article id="post-Python-OpenCV教程挑战任务1：画动态时钟" style="width: 66%; float:left;" class="article article-type-post" itemscope itemprop="blogPost" >
  <div id="articleInner" class="clearfix post-1016 post type-post status-publish format-standard has-post-thumbnail hentry category-template-2 category-uncategorized tag-codex tag-edge-case tag-featured-image tag-image tag-template">
    
<div class="article-gallery">
  <div class="article-gallery-photos">
    
      <a class="article-gallery-img fancybox" href="http://pic.ex2tron.top/cv2_draw_clock_dynamic_sample.gif" rel="gallery_cjxj6dycp001w5w59my4niwz6">
        <img src="http://pic.ex2tron.top/cv2_draw_clock_dynamic_sample.gif" itemprop="image">
      </a>
    
  </div>
</div>

    
      <header class="article-header">
        
  
    <h1 class="thumb" class="article-title" itemprop="name">
      Python+OpenCV教程挑战任务：画动态时钟
    </h1>
  

      </header>
    
    <div class="article-meta">
      
	Posted on <a href="/opencv-python-clock-drawing/" class="article-date">
	  <time datetime="2017-12-09T09:29:34.000Z" itemprop="datePublished">December 9, 2017</time>
	</a>

      
	<!-- TODO: ex2tron.wang 启用但暂时不显示访问量 2019年3月20日 -->
	<!-- <span id="busuanzi_container_page_pv">
	  本文总阅读量<span id="busuanzi_value_page_pv"></span>次
	</span> -->

    </div>
    <div class="article-entry" itemprop="articleBody">
      
        <p>挑战任务：使用OpenCV绘制一个随系统时间动态变化的时钟。<a id="more"></a></p>
<hr>
<h2 id="挑战内容"><a href="#挑战内容" class="headerlink" title="挑战内容"></a>挑战内容</h2><blockquote>
<p><strong>完成如下图所展示的动态时钟，时钟需随系统时间变化，中间显示当前日期。</strong></p>
</blockquote>
<p><img src="http://pic.ex2tron.top/cv2_draw_clock_dynamic_sample.gif" alt=""></p>
<p>其实本次任务涉及的OpenCV知识并不多，但有助于提升大家的编程实践能力。</p>
<p><strong>挑战题不会做也木有关系，但请务必在自行尝试后，再看下面的解答噢，</strong>不然…我也没办法(￣▽￣)”</p>
<hr>
<h2 id="挑战解答"><a href="#挑战解答" class="headerlink" title="挑战解答"></a>挑战解答</h2><h3 id="方案"><a href="#方案" class="headerlink" title="方案"></a>方案</h3><p>本次挑战任务旨在提升大家的动手实践能力，解决实际问题，所以我们得先有个解题思路和方案。观察下常见的时钟表盘：</p>
<p><img src="http://pic.ex2tron.top/cv2_draw_clock_actual_clock_sample.jpg" alt=""></p>
<p>整个表盘其实只有3根表针在动，所以可以先画出静态表盘，然后获取系统当前时间，根据时间实时动态绘制3根表针就解决了。</p>
<h3 id="绘制表盘"><a href="#绘制表盘" class="headerlink" title="绘制表盘"></a>绘制表盘</h3><p>表盘上只有60条分/秒刻线和12条小时刻线，当然还有表盘的外部轮廓圆，也就是重点在如何画72根线。先把简单的圆画出来：</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div></pre></td><td class="code"><pre><div class="line"><span class="keyword">import</span> cv2</div><div class="line"><span class="keyword">import</span> math</div><div class="line"><span class="keyword">import</span> datetime</div><div class="line"><span class="keyword">import</span> numpy <span class="keyword">as</span> np</div><div class="line"></div><div class="line">margin = <span class="number">5</span>  <span class="comment"># 上下左右边距</span></div><div class="line">radius = <span class="number">220</span>  <span class="comment"># 圆的半径</span></div><div class="line">center = (center_x, center_y) = (<span class="number">225</span>, <span class="number">225</span>)  <span class="comment"># 圆心</span></div><div class="line"></div><div class="line"><span class="comment"># 1. 新建一个画板并填充成白色</span></div><div class="line">img = np.zeros((<span class="number">450</span>, <span class="number">450</span>, <span class="number">3</span>), np.uint8)</div><div class="line">img[:] = (<span class="number">255</span>, <span class="number">255</span>, <span class="number">255</span>)</div><div class="line"></div><div class="line"><span class="comment"># 2. 画出圆盘</span></div><div class="line">cv2.circle(img, center, radius, (<span class="number">0</span>, <span class="number">0</span>, <span class="number">0</span>), thickness=<span class="number">5</span>)</div></pre></td></tr></table></figure>
<p><img src="http://pic.ex2tron.top/cv2_draw_clock_blank_circle.jpg" alt=""></p>
<p>前面我们使用OpenCV画直线的时候，需知道直线的起点和终点坐标，那么画72根线就变成了获取72组坐标。</p>
<p>在平面坐标系下，已知半径和角度的话，A点的坐标可以表示为：<br>$$<br>\begin{matrix}<br>   x=r\times \cos\alpha \newline<br>   y=r\times \sin\alpha<br>\end{matrix}<br>$$<br><img src="http://pic.ex2tron.top/cv2_draw_clock_center_shift.jpg" alt=""></p>
<p>先只考虑将坐标系原点移动到左上角，角度依然是平面坐标系中的逆时针计算，那么新坐标是：</p>
<p>$$<br>\begin{matrix}<br>   x=r+r\times \cos\alpha \newline<br>   y=r+r\times \sin\alpha<br>\end{matrix}<br>$$</p>
<p>对于60条分/秒刻线，刻线间的夹角是360°/60=6°，对于小时刻线，角度是360°/12=30°，这样就得到了72组起点坐标，那怎么得到终点坐标呢？其实同样的原理，用一个同心的小圆来计算得到B点：</p>
<p><img src="http://pic.ex2tron.top/cv2_draw_clock_a_b_position.jpg" alt=""></p>
<p>通过A/B两点就可以画出直线：</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div><div class="line">22</div><div class="line">23</div><div class="line">24</div></pre></td><td class="code"><pre><div class="line">pt1 = []</div><div class="line"></div><div class="line"><span class="comment"># 3. 画出60条秒和分钟的刻线</span></div><div class="line"><span class="keyword">for</span> i <span class="keyword">in</span> range(<span class="number">60</span>):</div><div class="line">    <span class="comment"># 最外部圆，计算A点</span></div><div class="line">    x1 = center_x+(radius-margin)*math.cos(i*<span class="number">6</span>*np.pi/<span class="number">180.0</span>)</div><div class="line">    y1 = center_y+(radius-margin)*math.sin(i*<span class="number">6</span>*np.pi/<span class="number">180.0</span>)</div><div class="line">    pt1.append((int(x1), int(y1)))</div><div class="line"></div><div class="line">    <span class="comment"># 同心小圆，计算B点</span></div><div class="line">    x2 = center_x+(radius<span class="number">-15</span>)*math.cos(i*<span class="number">6</span>*np.pi/<span class="number">180.0</span>)</div><div class="line">    y2 = center_y+(radius<span class="number">-15</span>)*math.sin(i*<span class="number">6</span>*np.pi/<span class="number">180.0</span>)</div><div class="line"></div><div class="line">    cv2.line(img, pt1[i], (int(x2), int(y2)), (<span class="number">0</span>, <span class="number">0</span>, <span class="number">0</span>), thickness=<span class="number">2</span>)</div><div class="line"></div><div class="line"><span class="comment"># 4. 画出12条小时的刻线</span></div><div class="line"><span class="keyword">for</span> i <span class="keyword">in</span> range(<span class="number">12</span>):</div><div class="line">    <span class="comment"># 12条小时刻线应该更长一点</span></div><div class="line">    x = center_x+(radius<span class="number">-25</span>)*math.cos(i*<span class="number">30</span>*np.pi/<span class="number">180.0</span>)</div><div class="line">    y = center_y+(radius<span class="number">-25</span>)*math.sin(i*<span class="number">30</span>*np.pi/<span class="number">180.0</span>)</div><div class="line">    <span class="comment"># 这里用到了前面的pt1</span></div><div class="line">    cv2.line(img, pt1[i*<span class="number">5</span>], (int(x), int(y)), (<span class="number">0</span>, <span class="number">0</span>, <span class="number">0</span>), thickness=<span class="number">5</span>)</div><div class="line"></div><div class="line"><span class="comment"># 到这里基本的表盘图就已经画出来了</span></div></pre></td></tr></table></figure>
<p><img src="http://pic.ex2tron.top/cv2_draw_clock_blank_clock.jpg" alt=""></p>
<h3 id="角度换算"><a href="#角度换算" class="headerlink" title="角度换算"></a>角度换算</h3><p>接下来算是一个小难点，首先<strong>时钟的起始坐标在正常二维坐标系的90°方向，其次时钟跟图像一样，都是顺时针计算角度的</strong>，所以三者需要统一下：</p>
<p><img src="http://pic.ex2tron.top/cv2_draw_clock_different_clock_contrast.jpg" alt=""></p>
<p>因为角度是完全对称的，顺逆时针没有影响，所以平面坐标系完全不用理会，放在这里只是便于大家理解。对于时钟坐标和图像坐标，时钟0的0°对应图像的270°，时钟15的90°对应图像的360°，时钟30的180°对应图像的450°（360°+90°）…</p>
<p>所以两者之间的关系便是：</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div></pre></td><td class="code"><pre><div class="line">计算角度 = 时钟角度+270°</div><div class="line">计算角度 = 计算角度 if 计算角度&lt;=360° else 计算角度-360°</div></pre></td></tr></table></figure>
<h3 id="同步时间"><a href="#同步时间" class="headerlink" title="同步时间"></a>同步时间</h3><p>Python中如何获取当前时间和添加日期文字都比较简单，看代码就行，我就不解释了。代码中角度计算我换了一种方式，其实是一样的，看你能不能看懂(●ˇ∀ˇ●)：</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div><div class="line">22</div><div class="line">23</div><div class="line">24</div><div class="line">25</div><div class="line">26</div><div class="line">27</div><div class="line">28</div><div class="line">29</div><div class="line">30</div><div class="line">31</div><div class="line">32</div><div class="line">33</div><div class="line">34</div><div class="line">35</div></pre></td><td class="code"><pre><div class="line"><span class="keyword">while</span>(<span class="number">1</span>):</div><div class="line">    <span class="comment"># 不断拷贝表盘图，才能更新绘制，不然会重叠在一起</span></div><div class="line">    temp = np.copy(img)</div><div class="line"></div><div class="line">    <span class="comment"># 5. 获取系统时间，画出动态的时-分-秒三条刻线</span></div><div class="line">    now_time = datetime.datetime.now()</div><div class="line">    hour, minute, second = now_time.hour, now_time.minute, now_time.second</div><div class="line"></div><div class="line">    <span class="comment"># 画秒刻线</span></div><div class="line">    <span class="comment"># OpenCV中的角度是顺时针计算的，所以需要转换下</span></div><div class="line">    sec_angle = second*<span class="number">6</span>+<span class="number">270</span> <span class="keyword">if</span> second &lt;= <span class="number">15</span> <span class="keyword">else</span> (second<span class="number">-15</span>)*<span class="number">6</span></div><div class="line">    sec_x = center_x+(radius-margin)*math.cos(sec_angle*np.pi/<span class="number">180.0</span>)</div><div class="line">    sec_y = center_y+(radius-margin)*math.sin(sec_angle*np.pi/<span class="number">180.0</span>)</div><div class="line">    cv2.line(temp, center, (int(sec_x), int(sec_y)), (<span class="number">203</span>, <span class="number">222</span>, <span class="number">166</span>), <span class="number">2</span>)</div><div class="line"></div><div class="line">    <span class="comment"># 画分刻线</span></div><div class="line">    min_angle = minute*<span class="number">6</span>+<span class="number">270</span> <span class="keyword">if</span> minute &lt;= <span class="number">15</span> <span class="keyword">else</span> (minute<span class="number">-15</span>)*<span class="number">6</span></div><div class="line">    min_x = center_x+(radius<span class="number">-35</span>)*math.cos(min_angle*np.pi/<span class="number">180.0</span>)</div><div class="line">    min_y = center_y+(radius<span class="number">-35</span>)*math.sin(min_angle*np.pi/<span class="number">180.0</span>)</div><div class="line">    cv2.line(temp, center, (int(min_x), int(min_y)), (<span class="number">186</span>, <span class="number">199</span>, <span class="number">137</span>), <span class="number">8</span>)</div><div class="line"></div><div class="line">    <span class="comment"># 画时刻线</span></div><div class="line">    hour_angle = hour*<span class="number">30</span>+<span class="number">270</span> <span class="keyword">if</span> hour &lt;= <span class="number">3</span> <span class="keyword">else</span> (hour<span class="number">-3</span>)*<span class="number">30</span></div><div class="line">    hour_x = center_x+(radius<span class="number">-65</span>)*math.cos(hour_angle*np.pi/<span class="number">180.0</span>)</div><div class="line">    hour_y = center_y+(radius<span class="number">-65</span>)*math.sin(hour_angle*np.pi/<span class="number">180.0</span>)</div><div class="line">    cv2.line(temp, center, (int(hour_x), int(hour_y)), (<span class="number">169</span>, <span class="number">198</span>, <span class="number">26</span>), <span class="number">15</span>)</div><div class="line"></div><div class="line">    <span class="comment"># 6. 添加当前日期文字</span></div><div class="line">    font = cv2.FONT_HERSHEY_SIMPLEX</div><div class="line">    time_str = now_time.strftime(<span class="string">"%d/%m/%Y"</span>)</div><div class="line">    cv2.putText(img, time_str, (<span class="number">135</span>, <span class="number">275</span>), font, <span class="number">1</span>, (<span class="number">0</span>, <span class="number">0</span>, <span class="number">0</span>), <span class="number">2</span>)</div><div class="line"></div><div class="line">    cv2.imshow(<span class="string">'clocking'</span>, temp)</div><div class="line">    <span class="keyword">if</span> cv2.waitKey(<span class="number">1</span>) == <span class="number">27</span>:  <span class="comment"># 按下ESC键退出</span></div><div class="line">        <span class="keyword">break</span></div></pre></td></tr></table></figure>
<p><img src="http://pic.ex2tron.top/cv2_draw_clock_sample.jpg" alt=""></p>
<p>本此挑战旨在锻炼一步步解决实际问题的思路（虽然有点数学知识(￣▽￣)”），大家再接再厉噢！</p>
<h2 id="引用"><a href="#引用" class="headerlink" title="引用"></a>引用</h2><ul>
<li><a href="https://github.com/ex2tron/OpenCV-Python-Tutorial/tree/master/%E6%8C%91%E6%88%98%E4%BB%BB%E5%8A%A11%EF%BC%9A%E7%94%BB%E5%8A%A8%E6%80%81%E6%97%B6%E9%92%9F" target="_blank" rel="external">本节源码</a></li>
</ul>

      
    </div>
    <footer class="entry-meta entry-footer">
      
	<span class="ico-folder"></span>
    <a class="article-category-link" href="/categories/机器视觉/">机器视觉</a>

      
  <span class="ico-tags"></span>
  <ul class="article-tag-list"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/OpenCV/">OpenCV</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/PyQt/">PyQt</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/Python/">Python</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/图像处理/">图像处理</a></li></ul>


      <div class="bdsharebuttonbox"><a href="#" class="bds_more" data-cmd="more"></a><a href="#" class="bds_qzone" data-cmd="qzone" title="分享到QQ空间"></a><a href="#" class="bds_tsina" data-cmd="tsina" title="分享到新浪微博"></a><a href="#" class="bds_weixin" data-cmd="weixin" title="分享到微信"></a></div>
      <script>window._bd_share_config={"common":{"bdSnsKey":{},"bdText":"","bdMini":"2","bdMiniList":false,"bdPic":"","bdStyle":"0","bdSize":"16"},"share":{},"image":{"viewList":["qzone","tsina","weixin"],"viewText":"分享到：","viewSize":"16"},"selectShare":{"bdContainerClass":null,"bdSelectMiniList":["qzone","tsina","weixin"]}};with(document)0[(getElementsByTagName('head')[0]||body).appendChild(createElement('script')).src='http://bdimg.share.baidu.com/static/api/js/share.js?v=89860593.js?cdnversion='+~(-new Date()/36e5)];</script>

      
        <div id="donation_div"></div>

<script src="/js/vdonate.js"></script>
  <script>
    var a = new Donate({
      title: '谢谢支持，我会更加✊~', // 可选参数，打赏标题
      // btnText: 'Donate', // 可选参数，打赏按钮文字
      btnText: '赏', // 可选参数，打赏按钮文字
      el: document.getElementById('donation_div'),
      wechatImage: '/img/wechat.jpg',
      alipayImage: '/img/alipay.jpg'
    });
  </script>
      
                  
      
        
	<div id="comment">
		<!-- 来必力City版安装代码 -->
		<div id="lv-container" data-id="city" data-uid="MTAyMC8yOTQ4MS82MDQ5">
		<script type="text/javascript">
		   (function(d, s) {
		       var j, e = d.getElementsByTagName(s)[0];

		       if (typeof LivereTower === 'function') { return; }

		       j = d.createElement(s);
		       j.src = 'https://cdn-city.livere.com/js/embed.dist.js';
		       j.async = true;

		       e.parentNode.insertBefore(j, e);
		   })(document, 'script');
		</script>
		<noscript>为正常使用来必力评论功能请激活JavaScript</noscript>
		</div>
		<!-- City版安装代码已完成 -->
	</div>


      
    </footer>
  </div>
  
    
<nav id="article-nav">
  
    <a href="/opencv-python-using-pyqt5-create-gui/" id="article-nav-newer" class="article-nav-link-wrap">
      <strong class="article-nav-caption">Newer</strong>
      <div class="article-nav-title">
        
          Python+OpenCV教程拓展挑战：PyQt编写GUI界面
        
      </div>
    </a>
  
  
    <a href="/opencv-python-extra-drawing-with-mouse/" id="article-nav-older" class="article-nav-link-wrap">
      <strong class="article-nav-caption">Older</strong>
      <div class="article-nav-title">Python+OpenCV教程番外篇6：鼠标绘图</div>
    </a>
  
</nav>

  
</article>

<!-- Table of Contents -->

  <aside id="sidebar">
    <div id="toc" class="toc-article">
    <strong class="toc-title">Contents</strong>
    
      <ol class="nav"><li class="nav-item nav-level-2"><a class="nav-link" href="#挑战内容"><span class="nav-number">1.</span> <span class="nav-text">挑战内容</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#挑战解答"><span class="nav-number">2.</span> <span class="nav-text">挑战解答</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#方案"><span class="nav-number">2.1.</span> <span class="nav-text">方案</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#绘制表盘"><span class="nav-number">2.2.</span> <span class="nav-text">绘制表盘</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#角度换算"><span class="nav-number">2.3.</span> <span class="nav-text">角度换算</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#同步时间"><span class="nav-number">2.4.</span> <span class="nav-text">同步时间</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#引用"><span class="nav-number">3.</span> <span class="nav-text">引用</span></a></li></ol>
    
    </div>
  </aside>
</section>
        
      </div>
      <footer id="footer" class="site-footer">
  

        <div class="clearfix container">
          <div class="site-info">
            &copy;
            <!-- 2019
              ex2tron&#39;s Tech Blog All Rights Reserved. -->
              Made by ex2tron | 2019
                <!-- TODO: ex2tron.wang 启用但暂时不显示访问量 2019年3月20日 -->
                <!--  -->
                  <!-- <span id="busuanzi_container_site_uv">
                    本站访客数
                    <span id="busuanzi_value_site_uv"></span>人次 本站总访问量
                    <span id="busuanzi_value_site_pv"></span>次
                  </span> -->
                  <!--  -->
          </div>
          <!-- <div class="site-credit">
            Theme by
              <a href="https://github.com/iTimeTraveler/hexo-theme-hiero" target="_blank">hiero</a>
          </div> -->
          <div>
            <p>&nbsp | 电影台词分享：
              <a href="http://moviequotes.ex2tron.wang/" style="font-weight: bold">MovieQuotes</a>
            </p>
          </div>
        </div>
</footer>


<!-- min height -->

<script>
  var contentdiv = document.getElementById("content");

  contentdiv.style.minHeight = document.body.offsetHeight - document.getElementById("allheader").offsetHeight - document.getElementById("footer").offsetHeight + "px";
</script>

<!-- Custome JS -->
<script src="/js/my.js"></script>
    </div>
    <!-- <nav id="mobile-nav">
  
    <a href="/" class="mobile-nav-link">Home</a>
  
    <a href="/archives" class="mobile-nav-link">Archives</a>
  
    <a href="/categories" class="mobile-nav-link">Categories</a>
  
    <a href="/tags" class="mobile-nav-link">Tags</a>
  
    <a href="/about" class="mobile-nav-link">About</a>
  
</nav> -->
    

<!-- mathjax config similar to math.stackexchange -->

<script type="text/x-mathjax-config">
  MathJax.Hub.Config({
    tex2jax: {
      inlineMath: [ ['$','$'], ["\\(","\\)"] ],
      processEscapes: true
    }
  });
</script>

<script type="text/x-mathjax-config">
    MathJax.Hub.Config({
      tex2jax: {
        skipTags: ['script', 'noscript', 'style', 'textarea', 'pre', 'code']
      }
    });
</script>

<script type="text/x-mathjax-config">
    MathJax.Hub.Queue(function() {
        var all = MathJax.Hub.getAllJax(), i;
        for(i=0; i < all.length; i += 1) {
            all[i].SourceElement().parentNode.className += ' has-jax';
        }
    });
</script>

<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML">
</script>


  <link rel="stylesheet" href="/fancybox/jquery.fancybox.css">
  <script src="/fancybox/jquery.fancybox.pack.js"></script>


<script src="/js/scripts.js"></script>
<script src="/js/bootstrap.js"></script>
<script src="/js/main.js"></script>







  <div style="display: none;">
    <script src="https://s95.cnzz.com/z_stat.php?id=1260716016&web_id=1260716016" language="JavaScript"></script>
  </div>



	<!-- <script async src="//dn-lbstatics.qbox.me/busuanzi/2.3/busuanzi.pure.mini.js"> -->
	<script async src="https://busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js">
	</script>






  </div>

  <a id="rocket" href="#top" class=""></a>
  <script type="text/javascript" src="/js/totop.js" async=""></script>
</body>
</html>
